All Questions
Tagged with text-processingsed
2,359 questions
0votes
5answers
78views
Match multiple vars across two lines and delete entire entry
MATCH1.MATCH2 { always same MATCH3 } All three MATCH(es) must match. input: foo.bar { always same bus } 1.2 { always same 3 } a.b { always same c } i.ii { always same iii } b.2 { ...
0votes
1answer
94views
Use sed to replace only part of a string
I'm trying to replace bobearl with jim in the following string "billy" "bobearl" and "johnny" I can do something like this: sed 's/bob/jim/' /tmp/text.txt "billy&...
1vote
3answers
84views
Loop ip list through geoiplookup and delete lines that do not match criteria
Thanks in advance for any ideas you present. My current project has me trying to loop a file containing a list of 1000's of IP addresses through geoiplookup and piping it to sed to delete all lines ...
3votes
5answers
645views
removing braces statements containing nested braces inside
A typical latex problem: \SomeStyle{\otherstyle{this is the \textit{nested part} some more text...}} Now I want to remove all \SomeStyle{...} but not the content. Content contains nested braces. The ...
1vote
3answers
76views
How do I merge bottom line with previous line? [duplicate]
I have a pretty basic file; 15 Chapter name some text and some more text some text and some more text I was trying to get something like this Book: 15 Chapter name some text and some more text some ...
0votes
2answers
89views
BSD sed/awk moving portion of line to line above (switching attribute in HTML file)
My situation is simple : I have an HTML file with several lines containing only the indented <section> block tag, each line followed by an (also indented) <h3 id="YYYY">...</...
0votes
2answers
103views
How to insert text before the first line of an UTF-8 with BOM file
This question is closely related to: How to insert text before the first line of a file?. I deliberately made the title similar to that question to highlight this. Except the target file is UTF-8 with ...
2votes
3answers
86views
Printing a specific section everytime search results are matched
I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References. This is what it looks like Chapter: 1 One: Birds and Trees Birds are beautiful and trees ...
2votes
5answers
128views
How to use sed to replace ID's in a file with names from a different file?
I'd like help writing a sed command to replace the ID's in one file with names from a different file. I have a file that looks like this: a b nSites J9 0 1 3092845 1 0 2 3139733 1 0 3 ...
2votes
5answers
532views
Move line matching string to top of the file
Need to move single line with PRM:TRG keyword to top of the file using sed File content: FOOBAR:SCN:NO_TRG FIZZBAR:SCN:NO_TRG BEBAR:PRM:TRG Output expected: BEBAR:PRM:TRG FOOBAR:SCN:NO_TRG FIZZBAR:...
1vote
3answers
112views
sed: To match a newline and spaces
I have a following file: <head> <title>this is a title</title> <style> here goes a style sheet </style> </head> I need to strip the <title> element ...
0votes
3answers
88views
Need to make multiple multiline replacements in file
I have a file with multiple "paragraphs" like this: <type>TRANS</type> <attributes/> <specification_method>rep_name</specification_method> <trans_object_id/&...
4votes
5answers
1kviews
Cut and replace Nth character on every row
I have predictable piped input, I want to iterate over each row and change two characters. the character positions are 19 and 20 (on every row.) The 19th character is a comma, I want to cut that. The ...
0votes
1answer
379views
Add \t to jq resulted array extraction
I want to add \t before each element in the resulting jq array and this is for formatting purposes as the result will get added to a file. here is the json file: { "array": ["...
0votes
5answers
126views
How can I replace the last occurrence of " before ] (text-manipulation)
I'm doing some text manipulation and I want to replace the last occurrence of " (with ", "four") before ] which could be in different lines. (this essentially adds a new item in ...